﻿using System;
using BusinessLayer.VDataEntities;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Http;
using System.Web.Http.Controllers;

namespace CustomerServiceCenter.Helper
{
    public class APIAuthorizeAttribute:AuthorizeAttribute
    {
        public override void OnAuthorization(HttpActionContext actionContext)
        {
            if (HttpContext.Current.Session["AdminInfo"] as VSuperDataEntity == null && HttpContext.Current.Session["PromoterInfo"] as VSuperDataEntity == null)
            {
                HttpContext.Current.Response.StatusCode = (int)System.Net.HttpStatusCode.Unauthorized;
                IsAuthorized(actionContext);
                HandleUnauthorizedRequest(actionContext);
            }
            else
            {
            } 
        }
        protected override bool IsAuthorized(System.Web.Http.Controllers.HttpActionContext actionContext)
        {
            return false;
        }
        protected override void HandleUnauthorizedRequest(HttpActionContext actionContext)
        {
            base.HandleUnauthorizedRequest(actionContext);
        }
    }
}